<?php
namespace Home\Logic;

class ScoreEventLogic {

    /**
     * 验证
     * @param $tag 行为标签
     */
    public static function checkStatus( $shopConfig, $tag ) {
        $driverConfig = array();
        $check = true;
        if ( isset($shopConfig['currency_config']['opened']) && $shopConfig['currency_config']['opened'] ) { // 商城币已启用
            /* 验证币值设置 */
            if ( $check ) {
                if ( empty($shopConfig['currency_config']['value']) ) {
                    $check = false;
                }
            }
            /* 验证事件配置 */
            if ( $check ) {
                $event = M("DistributionShopScoreEvent")->where(array('cid'=>$shopConfig['cid'], 'tag' => $tag))->find();
                if ( $event and $event['status'] ) {
                    $event['cfg'] and $event['cfg'] = unserialize($event['cfg']);
                    $event['cfg'] and $driverConfig = $event['cfg'];
                } else {
                    $check = false;
                }
            }
        } else {
            $check = false;
        }
        return array('check' => $check, 'driverConfig' => $driverConfig);
    }

}